<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Reactive Streams与JUC：构建高性能异步系统</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* 首字下沉效果 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.5rem;
            font-weight: 700;
            color: #4f46e5;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 代码块美化 */
        pre {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            position: relative;
        }
        
        pre::before {
            content: "CODE";
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 600;
            letter-spacing: 0.1em;
        }
        
        /* 表格美化 */
        table {
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        }
        
        /* 卡片悬停效果 */
        .card-hover {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .card-hover:hover {
            transform: translateY(-4px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        }
        
        /* 渐变文字效果 */
        .gradient-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        /* 动画效果 */
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
        
        /* 自定义滚动条 */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f5f9;
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb {
            background: #94a3b8;
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: #64748b;
        }
        
        /* Mermaid图表样式 */
        .mermaid {
            background: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="relative overflow-hidden bg-gradient-to-br from-indigo-600 via-purple-600 to-pink-500 text-white">
        <div class="absolute inset-0 bg-black opacity-20"></div>
        <div class="relative max-w-7xl mx-auto px-4 py-24 sm:px-6 lg:px-8">
            <div class="text-center animate-fadeInUp">
                <h1 class="text-5xl md:text-7xl font-bold mb-6 tracking-tight">
                    Reactive Streams
                    <span class="block text-3xl md:text-4xl mt-2 text-indigo-200">与 JUC 的完美融合</span>
                </h1>
                <p class="text-xl md:text-2xl text-indigo-100 max-w-3xl mx-auto leading-relaxed">
                    探索异步编程的新境界，构建高性能、高并发的现代化应用系统
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="flex items-center space-x-2">
                        <i class="fas fa-rocket text-2xl"></i>
                        <span class="text-lg">高性能</span>
                    </div>
                    <div class="flex items-center space-x-2">
                        <i class="fas fa-layer-group text-2xl"></i>
                        <span class="text-lg">异步非阻塞</span>
                    </div>
                    <div class="flex items-center space-x-2">
                        <i class="fas fa-shield-alt text-2xl"></i>
                        <span class="text-lg">背压控制</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0">
            <svg viewBox="0 0 1440 120" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M0 120L60 105C120 90 240 60 360 45C480 30 600 30 720 37.5C840 45 960 60 1080 67.5C1200 75 1320 75 1380 75L1440 75V120H1380C1320 120 1200 120 1080 120C960 120 840 120 720 120C600 120 480 120 360 120C240 120 120 120 60 120H0Z" fill="white"/>
            </svg>
        </div>
    </section>

    <!-- Main Content -->
    <main class="max-w-7xl mx-auto px-4 py-12 sm:px-6 lg:px-8">
        
        <!-- 引言部分 -->
        <section class="mb-16 animate-fadeInUp">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12 card-hover">
                <h2 class="text-3xl font-bold mb-6 text-gray-800 flex items-center">
                    <i class="fas fa-question-circle text-indigo-600 mr-3"></i>
                    为什么需要Reactive Streams？
                </h2>
                <p class="text-lg text-gray-700 leading-relaxed mb-6 drop-cap">
                    在现代高并发、高吞吐量的系统中，传统的同步阻塞模型已经无法满足需求。想象一下，你的系统需要处理数百万的并发请求，每个请求都可能涉及多个I/O操作（如数据库查询、远程服务调用等）。如果使用传统的同步模型，线程资源很快就会被耗尽，系统性能急剧下降。
                </p>
                <p class="text-lg text-gray-700 leading-relaxed">
                    <strong class="text-indigo-600">Reactive Streams</strong> 提供了一种全新的编程范式，通过异步非阻塞的方式，显著提升系统的吞吐量和响应速度。结合 <strong class="text-indigo-600">JUC（Java Util Concurrent）</strong>，我们可以构建出高性能、高可扩展的应用系统。
                </p>
            </div>
        </section>

        <!-- Reactive Streams基础 -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 text-center gradient-text">Reactive Streams 基础</h2>
            
            <!-- 核心概念卡片 -->
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <h3 class="text-2xl font-bold mb-4 text-gray-800">
                        <i class="fas fa-stream text-purple-600 mr-2"></i>
                        什么是Reactive Streams？
                    </h3>
                    <p class="text-gray-700 mb-4">
                        Reactive Streams 是一种异步流处理规范，旨在解决背压（Backpressure）问题。
                    </p>
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <i class="fas fa-paper-plane text-indigo-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">Publisher</strong>
                                <p class="text-gray-600 text-sm">数据发布者</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-inbox text-indigo-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">Subscriber</strong>
                                <p class="text-gray-600 text-sm">数据订阅者</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-link text-indigo-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">Subscription</strong>
                                <p class="text-gray-600 text-sm">订阅关系</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-exchange-alt text-indigo-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">Processor</strong>
                                <p class="text-gray-600 text-sm">既是Publisher又是Subscriber</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <h3 class="text-2xl font-bold mb-4 text-gray-800">
                        <i class="fas fa-cogs text-purple-600 mr-2"></i>
                        核心概念
                    </h3>
                    <div class="space-y-4">
                        <div class="bg-gradient-to-r from-indigo-50 to-purple-50 rounded-lg p-4">
                            <h4 class="font-semibold text-indigo-700 mb-1">异步非阻塞</h4>
                            <p class="text-gray-700 text-sm">不阻塞调用线程，提高资源利用率</p>
                        </div>
                        <div class="bg-gradient-to-r from-purple-50 to-pink-50 rounded-lg p-4">
                            <h4 class="font-semibold text-purple-700 mb-1">背压控制</h4>
                            <p class="text-gray-700 text-sm">订阅者可以控制数据流的速度，避免生产者压垮消费者</p>
                        </div>
                        <div class="bg-gradient-to-r from-pink-50 to-red-50 rounded-lg p-4">
                            <h4 class="font-semibold text-pink-700 mb-1">流式处理</h4>
                            <p class="text-gray-700 text-sm">数据以流的形式处理，支持丰富的操作符（如map、filter、flatMap等）</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 对比表格 -->
            <div class="bg-white rounded-xl shadow-lg p-8">
                <h3 class="text-2xl font-bold mb-6 text-gray-800">
                    <i class="fas fa-balance-scale text-indigo-600 mr-2"></i>
                    Reactive Streams vs 传统同步模型
                </h3>
                <div class="overflow-x-auto">
                    <table class="w-full">
                        <thead>
                            <tr class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white">
                                <th class="px-6 py-4 text-left">特性</th>
                                <th class="px-6 py-4 text-left">传统同步模型</th>
                                <th class="px-6 py-4 text-left">Reactive Streams</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr class="border-b hover:bg-gray-50 transition-colors">
                                <td class="px-6 py-4 font-medium">线程模型</td>
                                <td class="px-6 py-4 text-red-600">阻塞</td>
                                <td class="px-6 py-4 text-green-600">非阻塞</td>
                            </tr>
                            <tr class="border-b hover:bg-gray-50 transition-colors">
                                <td class="px-6 py-4 font-medium">资源利用率</td>
                                <td class="px-6 py-4 text-red-600">低</td>
                                <td class="px-6 py-4 text-green-600">高</td>